package top.wshape1.largefileupload.domain;

import lombok.Data;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2025-01-24
 */

@Data
public class R<T> {

    private int code;

    private String message;

    private T data;

    public static <T> R<T> ok() {
        return R.ok(null);
    }

    public static <T> R<T> ok(T data) {
        R<T> r = new R<>();
        r.setCode(0);
        r.setMessage("success");
        r.setData(data);
        return r;
    }

    public static <T> R<T> error() {
        return R.error("error");
    }

    public static <T> R<T> error(String message) {
        R<T> r = new R<>();
        r.setCode(1);
        r.setMessage(message);
        return r;
    }
}
